<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class con_principal extends CI_Controller 
{
 
	public function index()
	{
	    //$this->output->enable_profiler(TRUE);
	
        
        
                $this->form_validation->set_rules('username', 'username', 'required|trim|min_length[5]');		
		$this->form_validation->set_rules('password', 'password', 'required|trim|md5');		
		
		$this->form_validation->set_message('required', 'Debe introducir el campo %s');
		$this->form_validation->set_message('min_length', 'El campo %s debe ser de al menos %s carácteres');
		$this->form_validation->set_message('valid_email', 'Debe escribir una dirección de email correcta');
		$this->form_validation->set_message('matches', 'Los campos %s y %s no coinciden');
		
		if($this->form_validation->run()!=TRUE){
			$this->load->view('view_principal');	
		}else{
		  
			$data['username'] = $this->input->post('username');
			$data['password'] = $this->input->post('password');
            
            //print_r($data);
            
            $this->load->view('view_principal');
			//$this->load->view('exito_view', $data);
			
		}
	}
        function carga_principal() {
            $this->load->view('view_principal');            
        }
}
